package com.blackjack
{
	import com.blackjack.cards.*;
	
	import flash.net.SharedObject;

	public class Player
	{
		private var loses:uint;
		private var wins:uint;
		private var _money:Number;
		private var _deck:Deck;
		private var _stand:Boolean;
		
		public function Player()
		{
			_stand = false;
			initValues();
		}
		
		public function takeCard():void{
			deck.addCard(Stack.instance.takeCard());
		}
		
		private function initValues():void{
			var so:SharedObject = BlackJack.instance.sharedBlackJack;
			loses = so.data.loses;
			wins = so.data.wins;
			_money = so.data.money;
			_deck = new Deck;
		}
		
		public function get money():uint {return _money;}
		
		public function get deck():Deck {return _deck;}
		
		public function get stand():Boolean {return _stand;}
		public function set stand(value:Boolean):void{_stand = value;}
		
		public function update():void{
			deck.update();
			var fcPosx:int = 380-deck.deck.length*20
			for(var i:int = 0;i < deck.deck.length;i++){
				deck.deck[i].x = fcPosx+i*40;
				deck.deck[i].y = 450;
				deck.deck[i].open = true;
			}
		}
	}
}